package com.example.helloword.dto;

import com.example.helloword.config.DemoDateDeserializer;
import com.example.helloword.config.DemoDateSerializer;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

//ref https://www.cnblogs.com/mumuxinfei/p/4761374.html
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Message {
    private String userId; // 用户id
    private String message; // 消息实体

    //　　定义时间序列化的实现类.
    @JsonSerialize(using = DemoDateSerializer.class)
    @JsonDeserialize(using = DemoDateDeserializer.class) //string=>date的json转换支持
    private Date timestamp; // 时间信息, yyyy-MM-dd HH:mm:ss

    @JsonIgnore
    private String extra; // 额外附带信息

}
